package thread;

import java.util.concurrent.TimeUnit;

/**
 * @Author G_Y
 * @Date 2021/5/12 16:41
 * @Description: // TODO
 **/
public class Test {
    public static void main(String[] args) {
        Thread thread = new Thread(new MyRunnableTask());
        thread.start();
        System.out.println(Thread.currentThread().getName()+": main over");
    }
}
class MyRunnableTask implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+": MyRunnableTask Running ...");
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+": MyRunnableTask Over");
    }
}
class Test2 {
    public static void main(String[] args) {
        Thread thread = new MyThreadTask();
        thread.start();
        System.out.println(Thread.currentThread().getName()+": main over");
    }
}
class MyThreadTask extends Thread {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+": MyThreadTask Running ...");
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+": MyThreadTask Over");
    }
}
